package com.example.springbootsfzy.controller.liujinping.search;

import com.example.springbootsfzy.domain.SeachAll;
import com.example.springbootsfzy.service.liujinping.SearchConsultantService;
import com.example.springbootsfzy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/search")
public class SearchConsultantController {
    @Autowired
    private SearchConsultantService searchConsultantService;

    //搜索功能
    @GetMapping("/consultants")
    public R searchConsultants(String keyword) {
        System.out.println("搜索关键词：" + keyword);
        return R.ok(searchConsultantService.searchConsultants(keyword));
    }

    @GetMapping("/articles")
    public R searchSelectedArticles(String keyword) {
        return R.ok(searchConsultantService.searchSelectedArticles(keyword));
    }

    @GetMapping("/qaReplies")
    public R searchQaReplies(String keyword) {
        return R.ok(searchConsultantService.searchQaReplies(keyword));
    }
    @GetMapping("/all")
    public R searchQaQuestions(String keyword) {
        System.out.println("搜索关键词：" + keyword);
        SeachAll seachAll = new SeachAll();
        seachAll.setConsultants(searchConsultantService.searchConsultants(keyword));
        seachAll.setSelectedArticles(searchConsultantService.searchSelectedArticles(keyword));
        seachAll.setQaReplies(searchConsultantService.searchQaReplies(keyword));
        return R.ok(seachAll);
    }
}
